package org.jeecg.common.aspect;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.text.MessageFormat;

@Slf4j
@Data
public class AutoLogParam {
    @ApiModelProperty(hidden = true)
    private String detail;

    public void setDetail(String detail, Object... args) {
        try {
            if (args != null && args.length > 0) {
                if (detail.contains("%s")) {
                    this.detail = String.format(detail, args);
                } else {
                    this.detail = MessageFormat.format(detail, args);
                }
            } else this.detail = detail;
        } catch (Exception e) {
            this.detail = detail;
            log.error("AutoLogParam setDetail error", e);
        }
    }
}
